﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using TSVNAddin.Core;
using EnvDTE;

namespace TSVNAddin.VS.Test
{
	[TestFixture]
	public class VSCommandsBuilderFixture
	{
		[Test]
		public void AddCommand()
		{
			var resourceProxy = MockRepository.GenerateMock<ResourceProxy>();
			resourceProxy.Expect(x => x.GetString("AboutTortoiseSVN")).Return("About TortoiseSVN...");

			var commandsAdapter = MockRepository.GenerateMock<VSCommandsAdapter>(null, null);
			var command = MockRepository.GenerateStub<Command>();
			commandsAdapter.Expect(x => x.AddCommand("AboutTortoiseSVN", "About TortoiseSVN...", 59)).Return(command);

			VSCommandsBuilder builder = new VSCommandsBuilder(commandsAdapter, resourceProxy);
			Command addedCommand = builder.AddCommand(CommandType.AboutTortoiseSVN);

			Assert.AreSame(command, addedCommand);

			commandsAdapter.VerifyAllExpectations();
			resourceProxy.VerifyAllExpectations();
		}

		[Test]
		public void AddCommandWithDifferentKeyText()
		{
			var resourceProxy = MockRepository.GenerateMock<ResourceProxy>();
			resourceProxy.Expect(x => x.GetString("Update")).Return("Update...");

			var commandsAdapter = MockRepository.GenerateMock<VSCommandsAdapter>(null, null);
			var command = MockRepository.GenerateStub<Command>();
			commandsAdapter.Expect(x => x.AddCommand("ItemUpdate", "Update...", 1)).Return(command);

			VSCommandsBuilder builder = new VSCommandsBuilder(commandsAdapter, resourceProxy);
			Command addedCommand = builder.AddCommand(CommandType.ItemUpdate);

			Assert.AreSame(command, addedCommand);

			commandsAdapter.VerifyAllExpectations();
			resourceProxy.VerifyAllExpectations();
		}
	}
}
